package handlers

import (
	"awesome-devops/applications/backend/modules/requests"
	"awesome-devops/applications/backend/modules/services"
	awesomehttp "gitee.com/jjawesomejj/awesomehttp/system"
	"reflect"
)

type UserHandler struct {
	awesomehttp.HttpBaseHandler
}

func (context *UserHandler) GetModuleName() string {
	return "/api/login"
}
func (context *UserHandler) ActionAccount() interface{} {
	userName := requests.Input(context.HttpContext, "username", reflect.String).(string)
	password := requests.Input(context.HttpContext, "password", reflect.String).(string)
	service := services.UserService{}
	user := service.Login(userName, password)
	return map[string]interface{}{
		"access_token": user.AccessToken,
		"expired_at":   user.ExpiredAt,
	}
}
